/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pl.makimo.fuzzy.sets;

import pl.makimo.data.Record;
import pl.makimo.fuzzy.sets.memberships.MembershipFunction;

/**
 *
 * @author Mateusz Papiernik
 */
abstract public class FuzzySet<T> extends Set<T> {
	public MembershipFunction membershipFunction;
	public String column;
	
    public Object value(T element) {
		Object e = this.realValue(element);
		
		Object val = membershipFunction.value(e);
		
		return val == null ? 0.0 : (Double)val;
    }
    
    public Object realValue(Object element) {
    	if (element instanceof Number) {
    		Number e = (Number)element;
    		return (Double)e.doubleValue();
    	} else if (element instanceof Record && this.column != null) {
    		Record e = (Record)element;
    		return e.get(this.column);
    	}
    	
    	return element;
    }
    
    abstract public Set<T> support();
    abstract public double in();
    abstract public double crispCardinality();    
    abstract public double maxWithOne();
    abstract public double maxMembership();
}
